/***************************************************************************
 *   Copyright (C) 2007 - 2009 by Andreas Theofilu                         *
 *   andreas@theosys.at                                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation version 3 of the License.                *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

/*
 * Ported to KDE4 on Jul. 7 2009 by Andreas Theofilu.
 */
#include <KConfig>
#include <knuminput.h>
#include <kcombobox.h>
#include <kurlrequester.h>
#include <klineedit.h>
#include <qdir.h>
#include <qcheckbox.h>
#include <iostream>

#include "coordinateswidget.h"

using std::cout;
using std::endl;

coordinatesWidget::coordinatesWidget(QWidget* parent, Qt::WFlags fl)
		: QDialog(parent, fl), Ui::coordinatesWidgetBase()
{
QDir dir = QDir::home();
QString path = dir.absolutePath();

	setupUi (this);
	// Load the config parameters
	KConfig cfg(QString("sportwatcher.rc"), KConfig::SimpleConfig);
	KConfigGroup ic (&cfg, "ImageCoords");
	edLeftLon->setValue (ic.readEntry("LeftLon", 0.0));
	edLeftLat->setValue (ic.readEntry("LeftLat", 0.0));
	edRightLon->setValue (ic.readEntry("RightLon", 0.0));
	edRightLat->setValue (ic.readEntry("RightLat", 0.0));
	cbDate->setCurrentIndex(ic.readEntry("SRS", 0));
}

coordinatesWidget::~coordinatesWidget()
{
}

/*$SPECIALIZATION$*/
void coordinatesWidget::bpCancelSlot()
{
	done(QDialog::Rejected);
}

void coordinatesWidget::pbSaveSlot()
{
	KConfig cfg(QString("sportwatcher.rc"), KConfig::SimpleConfig);
	KConfigGroup ic (&cfg, "ImageCoords");
	// Put the data into the config file
	ic.writeEntry("LeftLon", edLeftLon->value());
	ic.writeEntry("LeftLat", edLeftLat->value());
	ic.writeEntry("RightLon", edRightLon->value());
	ic.writeEntry("RightLat", edRightLat->value());
	ic.writeEntry("SRS", cbDate->currentIndex());
	ic.sync();
	done(QDialog::Accepted);
}



#include "coordinateswidget.moc"

